/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* 主容器 */
.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* 头部样式 */
header {
    text-align: center;
    padding: 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 16px 16px 0 0;
}

header h1 {
    color: #4a5568;
    font-size: 28px;
    margin-bottom: 8px;
}

header p {
    color: #718096;
    font-size: 16px;
}

/* 主内容区 */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
}

/* 功能选择按钮 */
.function-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.function-selector button {
    padding: 12px 24px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 30px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.function-selector button:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.function-selector button.active {
    background: #667eea;
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* 面板样式 */
.panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.panel.hidden {
    display: none;
}

/* 翻译模式样式 */
.translation-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

.translation-box {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 200px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
}

.translation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
}

.translation-header span {
    color: #4a5568;
    font-weight: 500;
}

#swap-lang-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #667eea;
    font-size: 16px;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s ease;
}

#swap-lang-btn:hover {
    background: rgba(102, 126, 234, 0.1);
}

#source-text {
    flex: 1;
    padding: 16px;
    border: none;
    background: transparent;
    resize: none;
    font-size: 16px;
    line-height: 1.5;
}

#source-text:focus {
    outline: none;
}

.result-box {
    flex: 1;
    padding: 16px;
    background: #f8f9fa;
    overflow-y: auto;
    font-size: 16px;
    line-height: 1.5;
    color: #2d3748;
}

/* 对话模式样式 */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: #667eea;
    color: white;
    border-bottom-right-radius: 6px;
}

.message.ai {
    align-self: flex-start;
    background: #e2e8f0;
    color: #2d3748;
    border-bottom-left-radius: 6px;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    resize: none;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

#chat-input:focus {
    outline: none;
    border-color: #667eea;
}

/* 提交按钮 */
.submit-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.submit-btn:active {
    transform: translateY(0);
}

/* 加载动画 */
.loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.loading.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #4a5568;
    font-size: 16px;
}

/* 响应式设计 */
@media (max-width: 600px) {
    .container {
        max-height: 95vh;
        border-radius: 12px;
    }
    
    header h1 {
        font-size: 24px;
    }
    
    .function-selector button {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .chat-input-container {
        flex-direction: column;
    }
    
    .submit-btn {
        width: 100%;
    }
}